import com.zc.Role
import com.zc.User
import org.apache.shiro.crypto.hash.Sha256Hash
import org.springframework.http.HttpMethod

class BootStrap {

    def init = { servletContext ->
        def user = new User(username: "admin", passwordHash: new Sha256Hash("admin").toHex())
        user.addToPermissions("*:*")
        user.save()
        def role= new Role(name:"admin").addToUsers(user).save()
//        RequestMap.executeUpdate("delete from RequestMap")
//        [
//            ["/","IS_AUTHENTICATED_ANONYMOUSLY,ROLE_ANONYMOUS",null],
//            ["/login/auth","IS_AUTHENTICATED_ANONYMOUSLY",null]
//        ].each {
//            def rm = new RequestMap(url: it[0],configAttribute: it[1],httpMethod: it[2])
//            rm.save(flush: true)
//        }

    }
    def destroy = {
    }
}
